package com.chenx.study.intercepter;/**
 * @author chenx
 * @date 2021/11/4-10:00
 */

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 *@ClassName
 *@Description TODO
 *@Author chenx
 *@Date 2021/11/4 10:00
 **/
@Configuration
public class MyWebAppConfigurer implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        System.out.println("===自定义拦截器===");
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(new RequestInterceptor());
        //所有路径拦截
        interceptorRegistration.addPathPatterns("/**");
        //不拦截的路径
        interceptorRegistration.excludePathPatterns("/login/**", "/error");
       // super.addInterceptors(registry);
    }
}